# Contributor: John Boehr <jbboehr@gmail.com>
# Maintainer: Rafael del Valle <rvalle@privaz.io>
pkgname=handlebars
_pkgname=handlebars.c
pkgver=0.7.2
pkgrel=0
_mustachespec_ver="1.1.3"
_handlebarsspec_ver="4.0.5-p1"
pkgdesc="C implementation of handlebars.js"
url="https://github.com/jbboehr/handlebars.c"
license="LGPL-2.1-or-later"
arch="all !armv7 !mips !mips64"
makedepends="autoconf automake bison check-dev flex json-c-dev libtool lmdb-dev
	pcre-dev talloc-dev yaml-dev"
subpackages="$pkgname-dev $pkgname-utils"
source="$_pkgname-$pkgver.tar.gz::https://github.com/jbboehr/$_pkgname/archive/v$pkgver.tar.gz
	mustache-spec-$_mustachespec_ver.tar.gz::https://github.com/mustache/spec/archive/v$_mustachespec_ver.tar.gz
	handlebars-spec-$_handlebarsspec_ver.tar.gz::https://github.com/jbboehr/handlebars-spec/archive/v$_handlebarsspec_ver.tar.gz
	test_lmdb_cache.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	mkdir -p spec
	ln -sf "$srcdir"/spec-$_mustachespec_ver spec/mustache
	ln -sf "$srcdir"/handlebars-spec-$_handlebarsspec_ver spec/handlebars

	default_prepare

	./bootstrap
}

build() {
	./configure \
		--prefix=/usr \
		--disable-refcounting \
		--disable-static
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Handlebars command line utilities"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="d07dabc399377634cc817a9825a57e777777b7f9599afdbfd26ecf2b9cf1538833947fb037129c9542e0c3fc6c8959509b516187d30add8557a34e2e35b09f6d  handlebars.c-0.7.2.tar.gz
801a9cbf8a39080b183b20fbf327b420bcd6ed162bb58165dabafeb45fae277a9da506b6639ee7b955f6c206f0b8826d39588a43ffd86ab5ef4be6e9be2bc842  mustache-spec-1.1.3.tar.gz
81f0ff5ffc2d6b72465bdcbd2325d022faf73ec79586f3d8dfb07b7a6ec9147280872a82184b8d7ecdd8b22611b6b420c02ab437794bcd0aba67d2bf2082bc5d  handlebars-spec-4.0.5-p1.tar.gz
6cdfae1356019c06ce993cba9c5091713e51f22b21f3572aaa2b2d4b1b18cf68f120f1fcb93822a118352e2885bd4c20635ea22aedb31a438e43dc40a6be581a  test_lmdb_cache.patch"
